import matplotlib.pyplot as plt
import numpy as np
import matplotlib
from PIL import Image as PILImage
import io
data="""YSBS20255b-2009-1  0.155   0.1536  0.162725172
YSBS20255b-2009-2  0.43    0.4327  0.458406131
YSBS20255b-2009-3  0.67    0.6538  0.692641388
YSBS20255b-2009-5  0.0028  0.0027  0.002860403
YSBS20255b-2009-6  0.142   0.1394  0.147681568
YSBS20255b-2009-7  0.664   0.6183  0.65503238
GSB03-2453-2008-2  0.256   0.2409  0.255211548
GSB03-2453-2008-4  0.085   0.0849  0.089943796
YSBS11279-2000  0.803   0.7395  0.783432711
9902-GBW(E)010137   1.21    1.1099  1.175837682
Q235-YSBS11173a-2007    0.188   0.1942  0.205737164
16MnV5-YSBC35201-97-211 0.171   0.1646  0.174378667
Q345b-YSBS11264a-2011   0.158   0.1593  0.168763801
YSBS11078d-2012    0.0018  0.0016  0.001695054
BS1020 0.21    0.2138  0.226501573
GCr15-YSBS11273b-2007   0.999   0.962   1.01915114"""
data=data.split("\n")
for i in range(len(data)):
    data[i]=data[i].split(" ")
    data[i] = list(filter(lambda x: x!="", data[i]))
std=[]
measure=[]
yfited=[]
for i in range(len(data)):
    std.append(float(data[i][1]))
    measure.append(float(data[i][2]))
    yfited.append(float(data[i][3]))
print(measure,std,yfited)
matplotlib.use('qtAGG')
fig, ax = plt.subplots()  # Create a figure containing a single axes.
ax.plot(measure, std,'o')  # Plot some data on the axes.
ax.plot(measure,yfited)
# ax.scatter(measure,std,'-o')
# fig, ax = plt.subplots()  # Create a figure containing a single axes.
# ax.plot(measure, yfited)  # Plot some data on the axes.
plt.show()
# print(dir(plt))
# fio=io.BytesIO()
# plt.savefig(fio)
# img=PILImage.open(fio)
# print(dir(img))
# img.save("a.png")